package com.ibigcat.module.mdm.dao.mapper;

import java.util.*;

import com.ibigcat.framework.common.pojo.PageResult;
import com.ibigcat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ibigcat.framework.mybatis.core.mapper.BaseMapperX;
import com.ibigcat.module.mdm.dao.entity.UserDO;
import org.apache.ibatis.annotations.Mapper;
import com.ibigcat.module.mdm.controller.admin.user.vo.*;

/**
 * 人员 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserMapper extends BaseMapperX<UserDO> {

    default PageResult<UserDO> selectPage(UserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserDO>()
                .eqIfPresent(UserDO::getUserCode, reqVO.getUserCode())
                .likeIfPresent(UserDO::getUserName, reqVO.getUserName())
                .eqIfPresent(UserDO::getUserType, reqVO.getUserType())
                .eqIfPresent(UserDO::getUserNumber, reqVO.getUserNumber())
                .eqIfPresent(UserDO::getPhone, reqVO.getPhone())
                .eqIfPresent(UserDO::getMail, reqVO.getMail())
                .betweenIfPresent(UserDO::getEntryTime, reqVO.getEntryTime())
                .eqIfPresent(UserDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(UserDO::getSex, reqVO.getSex())
                .eqIfPresent(UserDO::getCompanyId, reqVO.getCompanyId())
                .eqIfPresent(UserDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(UserDO::getLoginPwd, reqVO.getLoginPwd())
                .eqIfPresent(UserDO::getDisabled, reqVO.getDisabled())
                .betweenIfPresent(UserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserDO::getId));
    }

}